package com.sztx.worker_monitor.core.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.sztx.se.core.service.StartupCallback;
import com.sztx.se.core.tbschedule.component.ScheduleManager;

@Component
public class StartupCallbackImpl implements StartupCallback {
	
	private Logger logger = LoggerFactory.getLogger(StartupCallbackImpl.class);
	
	@Autowired(required = false)
	private ScheduleManager scheduleManager;

	@Override
	public void businessHandle() {
		
		logger.info("启动完成, 准备初始化数据");
		
		if(!initData()){
			
			logger.error("初始化数据失败");
		}else{
			
			logger.info("初始化数据完成");
		}
		
	}

	private boolean initData(){
		try{
			scheduleManager.getAllTasks();
		}catch(Exception e){
			logger.error(e.toString());
			return false;
		}
		return true;
	
	}
	
}
		
		
		

